import { Navigate } from "react-router-dom";

const AuthRoute = (props) => {
  // children 为子组件
  const { children } = props;
  // 判断是否有token
  const token = localStorage.getItem("token");
  console.log(token);
  if (token) {
    // 允许跳转
    return <>{children}</>;
  } else {
    return <Navigate to="/login"></Navigate>;
    // navigateTo("/home/index");
  }
};
export default AuthRoute;
